package com.cmf.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cmf.config.LongToStringSerializer;
import com.cmf.enums.EmployeeStatus;
import com.cmf.enums.Gender;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 员工实体类
 * 用于管理系统员工信息
 * 
 * @Author: cmf
 * @Date: 2025/8/26
 * @Version: v1.0.0
 **/
@Data
@TableName("employee")
@Builder()
@AllArgsConstructor
@NoArgsConstructor
public class Employee implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = LongToStringSerializer.class)
    private Long id;

    /**
     * 姓名
     */
    @TableField("name")
    private String name;

    /**
     * 用户名
     */
    @TableField("username")
    private String username;

    /**
     * 密码
     */
    @TableField("password")
    private String password;

    /**
     * 手机号
     */
    @TableField("phone")
    private String phone;

    /**
     * 性别
     */
    @TableField("sex")
    private Gender sex;

    /**
     * 获取性别描述
     * @return 性别描述
     */
    public String getSexName() {
        return this.sex != null ? this.sex.getDesc() : null;
    }

    /**
     * 身份证号码
     */
    @TableField("id_number")
    private String idNumber;

    /**
     * 状态 0:禁用，1:正常
     */
    @TableField("status")
    private EmployeeStatus status;

    /**
     * 获取状态描述
     * @return 状态描述
     */
    public String getStatusName() {
        return this.status != null ? this.status.getDesc() : null;
    }

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 创建用户
     */
    @TableField(value = "create_user", fill = FieldFill.INSERT)
    private Long createUser;

    /**
     * 更新用户
     */
    @TableField(value = "update_user", fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;
}